package com.farm.command;

import com.farm.state.AgriculturalMachineContext;
import com.farm.state.IdleState;
import com.farm.state.WorkingState;

// 接收者类 - 农机设备
public class AgriculturalMachineReceiver {
    private String name;

    public AgriculturalMachineReceiver(String name) {
        this.name = name;
    }

    public void start() {
        System.out.println(name + ": 启动");

        // 4. 设置农机状态
        System.out.println(name + ": 设置农机状态为工作状态...");
        AgriculturalMachineContext stateContext = new AgriculturalMachineContext();
        stateContext.setState(new WorkingState());
        stateContext.request(name);
    }

    public void stop() {
        System.out.println(name + ": 停止");

        //设置农机状态为空闲状态
        AgriculturalMachineContext stateContext = new AgriculturalMachineContext();
        stateContext.setState(new IdleState());
        stateContext.request(name);
    }

    public void adjustSpeed(int speed) {
        System.out.println(name + ": 调整速度为 " + speed);
    }
}
